<?php
include('init.php'); //title, subtitle, menu

//breadcrumb
$breadcrumb = $lang['HOME'];

//contents
ob_start();
echo '<table>';
$sth = $dbh->prepare("SELECT * FROM forums ORDER BY display_order");
$sth->execute();
foreach($sth->fetchAll(PDO::FETCH_OBJ) as $forum){
	$sth = $dbh->prepare("SELECT lastposter,lastposted FROM topics WHERE forum_id=? ORDER BY lastposted LIMIT 1");
	$sth->execute(array($forum->id));
	$latest = $sth->fetchObject();
	echo '<tr><td><a href="viewforum.php?id='.$forum->id.'">'.$forum->forum_name."</a></td><td><i>";
	if($latest){
		echo strftime($lang['timeformat'],$latest->lastposted).'&nbsp;'.$latest->lastposter;
	}
	echo "</i></td></tr>\n";
	echo '<tr><td>&nbsp;&nbsp;'.$forum->forum_description."&nbsp;&nbsp;</td><td></td></tr>\n";
}
echo '</table>';
$contents = ob_get_clean();

//write template
include('footer.php');
exit();
?>